package com.tjp.oss.config;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.tjp.oss.adapter.StorangeAdapter;
import com.tjp.oss.adapter.AliStorangeAdapter;
import com.tjp.oss.adapter.MiniosStorangeAdapter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: jz-club
 * @description:
 * @author: aaronTang
 * @create: 2024-03-07
 */
@Configuration
@RefreshScope
public class StorangeConfig {

    @Value("${custom.type}")
    private String storangeType;


    @Bean
    @RefreshScope
    public StorangeAdapter storangeService() {
        if ("minio".equals(storangeType)) {
            return new MiniosStorangeAdapter();
        }else if ("aliyun".equals(storangeType)) {
            return new AliStorangeAdapter();
        }else {
            throw new IllegalArgumentException("未找到对应的文件存储处理器");
        }
    }

}
